@extends('admin.layouts.index')
@section('style', 'device')
@section('title', '-设备管理')
@section('content')
    <ol class="breadcrumb">
        <li><a href="{{url('charge/index.html')}}"><i class="icon icon-home"></i> 主页</a></li>
        <li class="active">设备管理</li>
    </ol>
    <div class="panel">
        <div class="panel-heading"><h5>设备列表</h5></div>
        <div class="panel-body">
            @if(count($device_list)>0)
            <table class="table">
                <thead>
                <tr>
                    <th width="50" class="text-center">设备ID</th>
                    <th width="100" class="text-center">设备名称</th>
                    <th width="100" class="text-center">设备类别</th>
                    <th width="300" class="text-center">设备参数</th>
                    <th width="100" class="text-center">参考代码</th>
                    <th width="100" class="text-center">二维码</th>
                    <th width="100" class="text-center">操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($device_list as $device)
                    <tr>
                        <td class="text-center">{{$device->device_id}}</td>
                        <td class="text-center">{{$device->device_name}}</td>
                        <td class="text-center">{{$device->belongsToCate->cate_name}}</td>
                        <td class="text-center">{{$device->device_description}}</td>
                        <td class="text-center"><a href="">点击查看</a></td>
                        <td class="text-center">
                            <a href="JavaScript:showcode({{$device->device_id}});" ><img width="50" src="{{url('charge/device/qrcode.html')}}?device_id={{$device->device_id}}"/></a>
                        </td>
                        <td class="text-center">
                            <a href="{{url('charge/device/delete.html')}}?device_id={{$device->device_id}}"><button type="button" class="btn btn-sm btn-danger"><i class="icon-trash"></i> 删除</button></a>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
                @else
                    <h3 style="text-align: center"><I>还没设备,请添加 ~</I></h3>
            @endif
        </div>
    </div>


    <!--二维码-->
    <div class="modal fade" id="code">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                    <h4 class="modal-title">二维码</h4>
                </div>
                <div class="modal-body">
                    <p style="text-align: center"><img width="50%" id="dcode"/></p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>

    <script>
        function showcode(did){
            var url="{{url('charge/device/qrcode.html')}}?device_id="+did;
            $('#dcode').attr('src',url);
            $('#code').modal('show');
        }
    </script>
@endsection
